package DP;

/**
 * @author chenhong
 * @version 1.0
 * @description TODO
 * @date 2023/4/19 12:16
 */
public class Offer46 {
    public static void main(String[] args) {
        Offer46 offer46 = new Offer46();

        System.out.println(offer46.translateNum(220));
    }
    public int translateNum(int num) {
        String s = String.valueOf(num);
        int n = s.length();
        int[] dp = new int[n];
        dp[0] = 1;
        for (int i = 1; i < n; i++) {
            if(s.charAt(i - 1)  == '0'){
                dp[i] = dp[i-1];
                continue;
            }
            int curNum = (s.charAt(i - 1) -'0') * 10 + s.charAt(i) - '0';
            if(curNum > 25){
                dp[i] = dp[i-1];
            }else if(i == 1) {
                dp[i] = 2;
            }else{
                dp[i] = dp[i-2] + dp[i-1];
            }

        }
        return dp[n -1];
    }
}
